import React from 'react';
import { BrowserRouter,Route, Redirect, Switch } from 'react-router-dom'
import { loadable } from 'utils';
// 直接加载
import App from './routes/App';

// 按需加载
const DetailPage = loadable(() =>
  import('./routes/DetailPage' /* webpackChunkName: 'DetailPage' */));
const SecondPage = loadable(() =>
  import('./routes/SecondPage' /* webpackChunkName: 'SecondPage' */));
const LogIn =loadable(() =>
  import('./routes/LogIn' /* webpackChunkName: 'LogIn' */));
const Register =loadable(() =>
  import('./routes/Register' /* webpackChunkName: 'Register' */));
const Agreement =loadable(() =>
  import('./routes/Agreement' /* webpackChunkName: 'Agreement' */));
const Editer =loadable(() =>
  import('./routes/Editer' /* webpackChunkName: 'Editer' */));

function RouterConfig() {
  return (
    <BrowserRouter>
      <Switch>
        <Route path="/" exact component={App} />
        <Route path="/detail" exact component={DetailPage} />
        <Route path="/login" exact component={LogIn} />
        <Route path="/register" exact component={Register} />
        <Route path="/agreement" exact component={Agreement} />
        <Route path="/editer" exact component={Editer} />
        <Route path="/list" exact component={SecondPage} />
      </Switch>
    </BrowserRouter>
  );
}

export default RouterConfig;
